package affichage;

import method.Tablier;
import java.awt.*;
import java.util.Set;
import javax.swing.*;
import no.geosoft.cc.graphics.*;

public class TablierGraph extends JFrame {

    public int size;
    public Tablier tablier;
    public int n;
    public String ret;
    public Set<Integer> ens;
    public int max;

    public TablierGraph(Tablier main) {
        super("Test : colorF2");
        this.tablier = main;
        this.max = main.getMax();
        this.n = main.getN();
        this.ens = main.getEns();
        size = n;
        initialize(size);
        affichage();

    }

    public void affichage() {
        ret = "";
        for (int j = 1 ; j <= n ; j++) {
            for (int i = 1 ; i <= n ; i++) {
                ret += tablier.getMap().get(tablier.getTab()[i][j]) + ",";
            }
            ret += '\n';
        }
        System.out.println(ret);
        System.out.println(ens.size());
    }

    public TablierGraph(int boardSize) {
        super("Test : colorF2");
        this.size = boardSize;
        initialize(boardSize);

    }

    private void initialize(int boardSize) {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        // Create the GUI
        JPanel topLevel = new JPanel();
        topLevel.setLayout(new BorderLayout());
        getContentPane().add(topLevel);
        // Create the graphic canvas
        GWindow window = new GWindow(new Color(220, 220, 220));
        topLevel.add(window.getCanvas(), BorderLayout.CENTER);
        // Create scene
        GScene scene = new GScene(window);
        double[] w0 = {0.0, 0.0, 0.0};
        double[] w1 = {boardSize + 2.0, 0.0, 0.0};
        double[] w2 = {0.0, boardSize + 2.0, 0.0};
        scene.setWorldExtent(w0, w1, w2);
        // Create  graphics representation
        GObject board = new Board(this);
        scene.add(board);
        pack();
        setSize(new Dimension(1000, 1000));
        setVisible(true);
    }
}
